package com.gd.iot.energy.controller.statistics;

import com.gd.iot.energy.annotation.SystemLogRecordMonitor;
import com.gd.iot.energy.consts.SystemConsts;
import com.gd.iot.energy.entity.ResponseEntity;
import com.gd.iot.energy.pojo.common.vo.PageVO;
import com.gd.iot.energy.pojo.common.vo.ChartVO;
import com.gd.iot.energy.pojo.statistics.dto.UserDosageChartDTO;
import com.gd.iot.energy.pojo.statistics.vo.UserDosageChartVO;
import com.gd.iot.energy.pojo.statistics.vo.UserDosagePageVO;
import com.gd.iot.energy.service.statistics.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 统计分析-用量分析-用户用量统计
 *
 * @author kris
 * @date Created at 2020/8/11 10:50
 */
@Api(value = "统计分析-用量分析-用户用量统计",tags = "统计分析-用量分析-用户用量统计")
@RestController
@RequestMapping("/admin/userDosage")
public class UserDosageController {

    @Autowired
    private StatisticsService statisticsService;

    @ApiOperation("用户用量分页列表")
    @SystemLogRecordMonitor("用户用量分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "archivesAddress", value = "表计地址", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "cycle", value = "统计周期，(日, 0)(月, 1)(季, 2)(年, 3)", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "date", value = "日期，如果季度，传 0,1,2,3", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "areaId", value = "区域id", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getUserDosagePageVO")
    public ResponseEntity<PageVO<UserDosagePageVO>> getUserDosagePageVO(
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "archivesAddress",required = false)String archivesAddress,
            @RequestParam(value = "cycle",required = true)String cycle,
            @RequestParam(value = "date",required = true)String date,
            @RequestParam(value = "areaId",required = false)Integer areaId,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum
    ) {

        PageVO<UserDosagePageVO> pageVO = statisticsService.getUserDosagePageVO(customerSerialnumber,customerName,
                archivesAddress,cycle,date,areaId,pageSize,pageNum);
        return new ResponseEntity<>(pageVO);
    }

    @ApiOperation("用户用量图表")
    @SystemLogRecordMonitor("用户用量图表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "archivesAddress", value = "表计地址", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "cycle", value = "统计周期，(日, 0)(月, 1)(季, 2)(年, 3)", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "date", value = "日期，如果季度，传 0,1,2,3", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "areaId", value = "区域id", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getUserDosageChartVO")
    public ResponseEntity<List<UserDosageChartVO>> getUserDosageChartVO(
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "archivesAddress",required = false)String archivesAddress,
            @RequestParam(value = "cycle",required = true)String cycle,
            @RequestParam(value = "date",required = true)String date,
            @RequestParam(value = "areaId",required = false)Integer areaId
    ) {

        List<UserDosageChartVO> chartVOS = statisticsService.getUserDosageChartVO(customerSerialnumber,customerName,
                archivesAddress,cycle,date,areaId);
        return new ResponseEntity<>(chartVOS);
    }
}
